
import java.awt.*;
import java.awt.event.*;


public class CompteurTestDec extends Frame {

	//private SharedObject cpt;
	static String myName;


	public static void main (String argv[]) {
		if (argv.length != 1) {
			System.out.println("java CompteurTest <name>");
			return;
		}
		myName = argv[0];

		// initialize the system
		Client.init();
		SharedObject c = null;
		// look up the IRC object in the name server
		// if not found, create it, and register it in the name server
		Compteur cpt = null;
		c = Client.lookup("CompteurTestDec");
		if (c == null) {
			cpt = new Compteur();
			c = Client.create(cpt);
			System.out.println(c.id);
			Client.register("CompteurTestDec", c);
		}
		c.lock_read();
		cpt.read();
		c.unlock();
		c.lock_write();
		for (int i= 1; i<10; i++){
			cpt.decrement();
		}
		c.unlock();
		c.lock_read();
		cpt.read();
		c.unlock();
	}
}






